package com.paotui.controller;

import cn.hutool.json.JSONUtil;
import com.paotui.common.R;
import com.paotui.pojo.Users;
import com.paotui.service.impl.UsersServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/users/update/info")
public class UsersUpdateController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Users users = new Users();
        users.setUsersID(Integer.parseInt(request.getParameter("UsersID")));
        users.setUsersName(request.getParameter("UsersName"));
        users.setUsersEmail(request.getParameter("UsersEmail"));
        UsersServiceImpl usersService = new UsersServiceImpl();
        usersService.updateById(users);
        usersService.getSqlSession().close();
        response.getWriter().write(JSONUtil.toJsonStr(R.success("修改成功")));


    }
}
